package com.mg.framework.kernel;

import android.graphics.Bitmap;
import android.util.Log;

import com.mg.framework.tiled.Map;
import com.mg.game.base.MenuScreen;

public class GameApplication {

	private MG mg;
	private String initScreenName;
	private Class<?> initScreenClass;
	public static GameApplication me;

	public GameApplication(MG mg) {
		this.mg = mg;
		this.me = this;
	}

	protected void setInitScreen(String initScreenName, Class<?> initScreenClass) {
		this.initScreenName = initScreenName;
		this.initScreenClass = initScreenClass;
	}

	Screen initScreen() {
		if (this.initScreenName != null && !"".equals(this.initScreenName)
				&& this.initScreenClass != null) {
			return ScreenFactory
					.newScreen(this.initScreenName, initScreenClass);
		}
		return ScreenFactory.newScreen("defaultGameScreen",
				DefaultGameScreen.class);
	}

	public void toMenuScreen() {
		if (this.getScreen("menu") == null) {
			ScreenFactory.newScreen("menu", MenuScreen.class);
		}
		ScreenFactory.changeScreen("menu");
	}

	public Screen getScreen(String screenName) {
		return ScreenFactory.getScreen(screenName);
	}

	public Screen newScreen(String screenName, Class<?> screenClass) {
		return ScreenFactory.newScreen(screenName, screenClass);
	}

	public void changeScreen(String screenName) {
		ScreenFactory.changeScreen(screenName);
	}

	public Bitmap loadingAssets(String fileName) {
		return Assets.loadingAssets(fileName);
	}

	public Map loadingTiledMapAssets(String basePath, String fileName, String tileObjectPackageName) {
		Log.i("Path", basePath + fileName);
		return Assets.loadingTiledMapAssets(basePath, fileName, tileObjectPackageName);
	}

	public Bitmap[] loadingAssets(String[] fileName) {
		return Assets.loadingAssets(fileName);
	}

	public MG getMG() {
		return this.mg;
	}
}
